How Do I Reference An Element By Name With [] Brackets In It?

Posted by user384030 on Stack Overflow See other posts from Stack Overflow or by user384030
Published on 2011-01-05T19:46:24Z Indexed on 2011/01/05 19:54 UTC
Read the original article Hit count: 83

Filed under:
|

How do you reference a element in jquery BY NAME that has the [] in it.

<select name="values[]" multiple="true">
<option value="1">1</option>
<option value="2">2</option>
<option value="2">2</option>
</select>

<script type="text/javascript">
$('[name=values[]]'); 
</script>

this should grab the element, but it does not work, I believe the [] in the name is messing it up, escaping it doesn't seem to work either. I can't figure out what I'm doing wrong

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery